package com.wayne.oauth2.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wayne.oauth2.http.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class WayneResponse {
    private int code;
    private String message;
    private Object data;
    public static WayneResponse build() {
        return build(null);
    }
    public static WayneResponse build(Object data) {
        return new WayneResponse(200, "成功", data);
    }
    public static WayneResponse buildFail(HttpStatus status) {
        return buildFail(status.getCode(), status.getMassage());
    }
    private static WayneResponse buildFail(Integer code, String massage) {
        return new WayneResponse(code, massage, null);
    }
}
